<script setup>
const props = defineProps({
  info: {
    type: String,
    default: "确定"
  },
  before: {
    type: String
  },
  after: {
    type: String
  }
});

const beforeColor = ref({"background": props.before});
const afterColor = ref({"background": props.after});
</script>

<template>
  <div class="myButton">
    <div :style="beforeColor">{{ props.info }}</div>
    <div :style="afterColor">{{ props.info }}</div>
    <div :style="afterColor">{{ props.info }}</div>
  </div>
</template>

<style scoped lang="less">
.myButton {
  cursor: pointer;
  user-select: none;
  position: relative;
  width: 66px;
  height: 33px;
  border-radius: 4px;
  color: var(--white);
  font-size: 14px;
  overflow: hidden;

  div {
    width: 66px;
    height: 33px;
    line-height: 33px;
    border-radius: 4px;
    text-align: center;
    position: absolute;

    &:nth-child(2) {
      width: 100px;
      transition: all 0.3s ease;
      transform: translateX(-120px) skewX(-30deg);
    }

    &:nth-child(3) {
      transition: all 0.3s ease;
      transform: translateX(-120px);
    }
  }

  &:hover div:nth-child(2) {
    transform: translateX(20px) skewX(-30deg);
  }

  &:hover div:nth-child(3) {
    transform: translateX(0px);
  }
}

</style>